package com.jg.test.Page;

import com.jg.test.AnyTest;

import java.lang.reflect.Field;

// 选择技能
public class Battle001 extends Page {
    public static int choice;
    public static int skillNum;
    @Override
    public void effect()
            throws IllegalAccessException, NoSuchMethodException {

        Class<?> clazz = AnyTest.team.get(4).getClass();
        Field[] declaredFields = clazz.getDeclaredFields();
        // 指示可使用技能个数
        skillNum = 0;
        for (int i = 5, j = 0; i < declaredFields.length - 5; i++, j++) {
            skillNum++;
            declaredFields[i].setAccessible(true);
            System.out.println(j + "." + declaredFields[i].get(AnyTest.team.get(4)));
        }

    }

    @Override
    public void sendMessage() {
        System.out.println("选择要使用的技能，按"+skillNum+ "返回");
        choice = Page.numGet(skillNum);
        if (choice == skillNum){
            AnyTest.team.remove(AnyTest.team.size()-1);
        }
    }

    @Override
    public void next() {
        if (choice == skillNum){
            AnyTest.pageNavigation.add(new Battle000());
        }else {
            AnyTest.pageNavigation.add(new Battle002());
        }
    }
}
